/**
 * 插件机制 考虑一个页面 可能有多个列表组件  故参数不能共享 否则会被覆盖
 */
import { postAction } from '@/api/manage'
import {
//   findComponentUpward,
//   findComponentsUpward,
//   findComponentDownward,
  findComponentsDownward
//   findBrothersComponents
} from '@/utils/assits'

export default {
  data () {
    return {
      stack: {}
    }
  },
  mounted () {
    console.log('this', this, findComponentsDownward(this, 'List'))
  },
  methods: {
    // 获取查询条件
    getQueryParams ({ queryParam, ipagination }) {
      let params = Object.assign({}, queryParam)
      params.pageNo = ipagination.pageNo
      params.pageSize = ipagination.pageSize
      return params
    },
    reload (arg) {
      this.stack[arg._uid] = arg
      console.log('stack', this.stack, 'uid', this.uid)
      this.loadPagenationData(arg)
    },
    loadPagenationData (arg) {
      console.log('arg', arg)
      // this.setOptions(arg)
      if (!arg.url) {
        console.error('请设置url属性!')
        return false
      }
      const params = this.getQueryParams(arg)
      return postAction(arg.url, params).then(res => {
        console.log('res', res)
        this.processList(res, arg._instance)
      }).catch(err => {
        console.log('err', err)
      })
    },
    processList (data) {
      console.log('回调', data)
    }
  }
}
